package com.lunar.controller;

import cn.hutool.http.server.HttpServerResponse;
import com.lunar.entity.TelVisit;
import com.lunar.service.TelVisitService;
import net.sf.jsqlparser.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/Tel")
public class TelVisitController {
    @Autowired
    private TelVisitService telVisitService;

    @RequestMapping("/getAllTel")
    public List<TelVisit> getAllTel(){
        return telVisitService.getAllTel();
    }

    @PostMapping("/addTel")
    public String addTel(TelVisit telVisit){
        int count  = telVisitService.addTelVisit(telVisit);
        return "redirect:/addOver";
    }

    @RequestMapping("/addOver")
    public void addOver(HttpServletResponse response) throws IOException {
        response.sendRedirect("/add");
    }

    @GetMapping("/getOneCompTel")
    public List<TelVisit> getOneCompTel(int cid){
        return telVisitService.selectTal(cid);
    }

}
